package com.zjk.controller;

import com.zjk.Result;
import com.zjk.category.CategoryEntity;
import com.zjk.dto.CategoryDTO;
import com.zjk.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: gfk
 * @create: 2022/10/19
 * @Description:
 * @FileName: CategoryController
 * @History:
 * @自定义内容：
 */
@RestController
@RequestMapping("/product/category")
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    @GetMapping("/findTreeCategoryDTO")
    public List<CategoryDTO> findTreeCategoryDTO(){
        return categoryService.findTreeCategoryDTO();
    }


    @GetMapping("listTreeCategoryDTO")
    public List<CategoryDTO> listTreeCategoryDTO(){
        return categoryService.listTreeCategoryDTO();
    }

    @PostMapping("save")
    public Result save(@RequestBody CategoryEntity categoryEntity){
        return categoryService.save(categoryEntity);
    }

    @GetMapping("seleteById/{catId}")
    public CategoryEntity seleteById(@PathVariable Long catId){
        return categoryService.seleteById(catId);
    }

    @GetMapping("deleteById/{catId}")
    public Result deleteById(@PathVariable Long catId){
        return categoryService.deleteById(catId);
    }
}
